package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

/**
 * @author 42
 * @date 2025/3/28
 * @Description
 */
@Mapper
public interface UserMapper {
    /**
     * 根据open_id查询用户信息
     * @param openid
     * @return
     */
    @Select("SELECT * FROM user WHERE openid = #{openid}")
    User selectByOpenId(String openid);


    /**
     * 插入用户，并返回主键
     * @param user
     */
    void insert(User user);

    @Select("SELECT * FROM user Where id = #{id}")
    User getById(Long id);

    /**
     * 统计用户数量
     * @param min
     * @param max
     * @return
     */
    Integer getUserCount(@Param("min") LocalDateTime min, @Param("max") LocalDateTime max);
}
